package com.example.egmv2.controller;

import com.example.egmv2.mapper.AddressMapper;
import com.example.egmv2.pojo.entity.Address;
import com.example.egmv2.pojo.vo.AddressVo1;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/address/")
public class AddressController {
    @Autowired(required = false)
    private AddressMapper addressMapper;

    @RequestMapping("insert")
    public String insertAddress(AddressVo1 addressVo1) {
        Address address = new Address();
        BeanUtils.copyProperties(addressVo1, address);
        addressMapper.insertAddress(address);
        return "添加成功";
    }

    @RequestMapping("select")
    public List<Address> selectAddress(){
        return addressMapper.selectAddress();
    }




}
